// [[ OnflowGenerator File UUID: d89db3383d5b4508bff3426e5433ccbc  ]]
package com.itdct.onflow.system.api.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.api.qo.SysApiEditQo
import com.itdct.onflow.system.api.qo.SysApiSearchQo
import com.itdct.onflow.system.api.service.SysApiService
import com.itdct.onflow.system.api.vo.SysApiDetailVo
import com.itdct.onflow.system.api.vo.SysApiListVo
import com.itdct.onflow.system.common.base.BaseSysController
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-01 15:08:45
 * @version 1.0
 * @description 系统接口接口控制
 */
@Tag(name = SysApiController.moduleName)
@RestController
@RequestMapping(value = ["/sysApi"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysApiController(
    val sysApiService: SysApiService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统接口"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysApiEditQo): RespVo<Long> {
        return sysApiService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysApiEditQo): RespVo<Unit> {
        return sysApiService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysApiEditQo): RespVo<Unit> {
        return sysApiService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysApiSearchQo): RespVo<SysApiDetailVo> {
        return sysApiService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysApiSearchQo): RespPageVo<SysApiListVo> {
        return sysApiService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "刷新角色接口权限")
    @PostMapping("/refreshApiRole.adw")
    fun refreshApiRole(): RespVo<Unit> {
        return sysApiService.refreshApiRole(getContext())
    }

    @Operation(summary = moduleName + "自动绑定菜单接口")
    @PostMapping("/autoBindApiMenu.adw")
    fun autoBindApiMenu(): RespVo<Unit> {
        return sysApiService.autoBindApiMenu(getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "接口名称下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysApiSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysApiService.selectNameList(qo, getContext())
    }

    @Operation(summary = moduleName + "接口地址下拉选")
    @PostMapping("/selectUrlList.adw")
    fun selectUrlList(@RequestBody qo: SysApiSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysApiService.selectUrlList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}